<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .box1 {
            position: relative;
            width: 300px;
            height: 300px;
            margin: 0 auto;
            border: 1px solid #000;
        }
        .box1 .box2 {
            position: absolute;
            width: 150px;
            height: 150px;
            border: 1px solid #f00;
            left: 50%;
            top:50%;
            margin-left: -75px;
            margin-top: -75px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>
    </div>
</body>
</html>